package unamur.iodass.app;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import unamur.iodass.accountancy.Accountancy;
import unamur.iodass.communication.Communication;
import unamur.iodass.communication.messages.BookStore;


public class Main {
	private static final Logger logger = Logger.getLogger(Main.class);

	public static void main(String[] args) {


		ProjectProperties properties = new ProjectProperties();


		PropertyConfigurator.configure(properties.getProjectProperty("log4jPath"));

		Communication com = Communication.getInstance();
		com.startServer();

		Accountancy accountancy = Accountancy.getInstance();
		BookStore bs = new BookStore(
				properties.getProjectProperty("nameBookStore"), 
				properties.getProjectProperty("adressBookStore"), 
				properties.getProjectProperty("ipBookStore"), 
				Integer.valueOf(properties.getProjectProperty("portBookStore")));
		accountancy.setBookStore(bs);

		logger.info("/**************************************");
		logger.info("             BOOKTSTORE");
		logger.info("Name = " + bs.getName());
		logger.info("IP = " + bs.getIp());
		logger.info("Port = " + bs.getPort());
		logger.info("FichierCSV = " + properties.getProjectProperty("fichierCSV"));
		logger.info("/**************************************");

		accountancy.generateBookStorePrice();

		com.async(bs, properties.getProjectProperty("ipOnlineLibrary"), Integer.valueOf(properties.getProjectProperty("portOnlineLibrary")));

	}

}